#include "TrainingSet.h"
#include "Helper.h"

using namespace NeuralPlusPlus::Core;

TrainingSample* NeuralPlusPlus::Core::TrainingSet::operator[]( int index )
	{
	return TrainingSamples[index];
	}

NeuralPlusPlus::Core::TrainingSet::TrainingSet( int inputVectorLength, int outputVectorLength )
	{
	Helper::ValidatePositive(inputVectorLength, "inputVectorLength");
	Helper::ValidateNotNegative(outputVectorLength, "outputVectorLength");

	this->InputVectorLength = inputVectorLength;
	this->OutputVectorLength = outputVectorLength;
	}

void NeuralPlusPlus::Core::TrainingSet::Add( TrainingSample *sample )
	{
	Helper::ValidateNotNull(sample, "sample");
	if (sample->InputVectorLength != InputVectorLength)
		{
		throw ("Input vector must be of size %d sample", InputVectorLength);
		}
	if (sample->OutputVectorLength != OutputVectorLength)
		{
		throw ("Output vector must be of size %d sample", OutputVectorLength);
		}

	TrainingSamples.push_back(sample);
	}

void NeuralPlusPlus::Core::TrainingSet::Clear()
	{
	TrainingSamples.clear();
	}

NeuralPlusPlus::Core::TrainingSet::~TrainingSet()
	{
	Clear();
	}
